package utils

import (
	"crypto/md5"
	"encoding/base64"
	"encoding/hex"
	"log"
)

func Base64(str string) string {
	input := []byte(str)
	return coder.EncodeToString(input)
}

func DeBase64(str string) string {
	decodeBytes, err := coder.DecodeString(str)
	if err != nil {
		log.Fatalln(err)
	}
	return string(decodeBytes)
}

const base64Table = "ABCD56EKijklmnopqLMNOPQ23RSTUVW89XYZabcdeFGHIJfghrstuvwxyz0147+/"

var coder = base64.NewEncoding(base64Table)

func base64Encode(encode_byte []byte) []byte {
	return []byte(coder.EncodeToString(encode_byte))
}
func base64Decode(decode_byte []byte) ([]byte, error) {
	return coder.DecodeString(string(decode_byte))
}
func MD5(b []byte) string {
	h := md5.New()
	h.Write(b)
	x := h.Sum(nil)
	y := make([]byte, 32)
	hex.Encode(y, x)
	return string(y)
}
